import "reflect-metadata";
import {get, Controller} from '../decorator'
import {Request, Response} from 'express'
import {getSession} from '../util/SessionUtil';

@Controller("/")
class MainController {

    @get('/')
    index(req: Request, res: Response): void {
        if (getSession(req).userInfo) {
            let htmlstr = `<div><a href='/food/searchFoodHistory' style='text-decoration:none;color:red'>搜索美食历史信息</a></div>
                           <div><a href = '/order/orderInfo' style='text-decoration:none;color:red'>订单信息</a></div>
                           <div><a href="/user/logout" style='text-decoration:none;color:red'>注销</a></div>`;
            res.send(htmlstr);
        } else {
            res.redirect("/user/login");
        }
    }
}
